package com.lagou.mr.homework1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class HomeworkReduce extends Reducer<IntWritable,IntWritable,IntWritable,IntWritable> {

    private IntWritable p = new IntWritable(1);

    @Override
    protected void reduce(IntWritable key, Iterable<IntWritable> values, Reducer<IntWritable, IntWritable, IntWritable, IntWritable>.Context context) throws IOException, InterruptedException {
        for (IntWritable value : values) {
            context.write(p,key);
            p = new IntWritable(p.get()+1);

        }
    }
}
